/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 马拉圈
 * Date: 2023-03-22
 * Time: 23:26
 */
public class Test {

    volatile public static int flag;
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            while(flag == 0) {

            }
            System.out.println("thread线程over");
        });
        Thread thread1 = new Thread(() -> {
            try {
                Thread.sleep(2);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            flag = 1;
        });
        thread.start();
        thread1.start();
    }
}
